<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php echo $this->headTitle()?>
<style>
p {line-height:12pt}
.mainTable {width:700px; border-collapse: collapse; text-align: center;font-family: 標楷體;font-size:12px;}
.mainTable h1 {font-size:18px}
.mainTable tbody{white-space: nowrap;}
.childTitle {font-size:16px;}
.childTitle2 {font-size:16px; border-top: 0.75pt solid windowtext; border-right: 0.75pt solid windowtext; border-bottom: 0.75pt solid windowtext; text-align: center; padding-left:1.4pt; padding-right:1.4pt; padding-top:0cm; padding-bottom:0cm}
.border-left {border-left:1.5pt solid windowtext; border-right:0.75pt solid windowtext; border-top:0.75pt solid windowtext; border-bottom:0.75pt solid windowtext; padding-left:1.4pt; padding-right:1.4pt; padding-top:0cm; padding-bottom:0cm}
.border-center {border-width: 1.5pt 1px 0.75pt medium; border-top: 0.75pt solid windowtext;  border-left: 1px solid windowtext; border-right: 1px solid windowtext; border-bottom: 0.75pt solid windowtext; padding: 0cm 1.4pt;}
.border-right {border-style: solid solid solid none; border-width: 1.5pt 1.5pt 0.75pt medium; border-top: 0.75pt solid windowtext; border-right: 1.5pt solid windowtext; border-bottom: 0.75pt solid windowtext; padding: 0cm 1.4pt}
.border-top-solid {border-top: 1.5pt solid windowtext;}
.border-bottom-solid {border-bottom: 1.5pt solid windowtext;}
.failed {color: red; font-weight: bold;}
</style>
<script type="text/javascript" src="<?php echo $this->js('jquery-1.3.2.min.js')?>"></script>
<script type="text/javascript">
$(document).ready(function(){
    $.each($(".score"),function(){
     var s = $(this).text();
            if (s == '' )
                $(this).html('-');
            else if(s < 60)
                $(this).addClass('failed');
         });
    $('#clone-table').html($('#first-table tbody').clone());
    $('#clone-table .saved').html('(<?php echo $this->translate('Registry staff saved')?>)');
    $('#clone-table .saved-memo').html('<?php echo $this->translate('Registry staff saved memo')?>');

    if (window.confirm('<?php echo $this->translate("To start printing?")?>')){
      self.print();
     }
});
</script>
</head>
<?php $flag=false;?>
<div id="scoreDataList">

<table class="mainTable">
<caption>
<span class="childTitle"><?php echo $this->School['name']?></span><br />
<span style="font-size:14px"><?php echo sprintf($this->translate('%d No. %d academic year semester'),$this->Semester['year'],$this->Semester['semester'])?>
                <?php echo $this->className?>
                <?php if ($this->stage == 255):?>
                <?php echo $this->translate('whole stage score')?>
                <?php else:?>
                <?php echo sprintf($this->translate('%dth stage'),$this->stage)?>
                <?php endif?>
                <?php echo $this->translate('Score list')?>
</span>
<?php if ($this->plusCount or $this->rateCount):?>
( <?php if ($this->plusCount):?><span id="pludMemo">* <?php echo $this->translate('usually score counted')?></span><?php endif?>
 <?php if ($this->rateCount):?><span id="reateMemo">* <?php echo $this->translate('rate counted')?></span><?php endif?>)
<?php endif?>
<p style="text-align:right;"><?php echo $this->translate('printed time')?>: <?php echo date('Y-m-d H:i:s')?></p>
</caption>
<thead>
<tr class="border-top-solid">
<th rowspan="2"  class="border-left"><?php echo $this->translate('number')?></th>
<th rowspan="2"  class="border-center"><?php echo $this->translate('student name')?></th>
<?php foreach($this->subject as $scopeName=>$val):?>
<?php if (count($val) >1):?>
<?php $flag = true;?>
<th colspan="<?php echo count($val)?>"  class="border-center"><?php echo $scopeName?></th>
<?php else:?>
<th rowspan="2"  class="border-center"><?php echo $val[0]['name']?>
<?php if ($this->rateCount):?><br/><span class="rate">(<?php echo $val[0]['rate']?>)</span><?php endif?>
</th>
<?php endif;?>
<?php endforeach?>
<th rowspan="2"  class="border-center"><?php echo $this->translate('Total score')?></th>
<?php if ($this->rankPrint):?>
<th rowspan="2"  class="border-center"><?php echo $this->translate('Average score')?></th>
<th rowspan="2" class="border-right"><?php echo $this->translate('Rank')?></th>
<?php else:?>
<th rowspan="2"  class="border-right"><?php echo $this->translate('Average score')?></th>
<?php endif;?>
</tr>
<?php if ($flag):?>
<tr>
<?php foreach($this->subject as $val):?>
<?php if (count($val) > 1):?>
<?php foreach($val as $row):?>
<th class="border-center"><?php echo $row['name']?>
<?php if ($this->rateCount):?><br/><span class="rate">(<?php echo $row['rate']?>)</span><?php endif?>
</th>
<?php endforeach?>
<?php endif?>
<?php endforeach?>
</tr>
<?php endif?>
</thead>
<tbody>
<?php foreach ($this->studentScore['score'] as $val):?>
<tr>
<td class="border-left"><?php echo $val['number']?></td>
<td class="border-center"><?php echo $val['name']?></td>
<?php foreach($this->subject as $subjectArr):?>
<?php foreach($subjectArr as $row):?>
<td class="score border-center"><?php if (isset($val['score'][$row['subject_sn']]))echo $val['score'][$row['subject_sn']]?></td>
<?php endforeach?>
<?php endforeach?>
<td class="score border-center "><?php echo $val['total']?></td>
<?php if ($this->rankPrint):?>
<td class="score border-center"><?php echo $val['average']?></td>
<td  class="border-right" style="text-align:right;padding:2px"><?php echo $val['sort']?></td>
<?php else:?>
<td class="score border-right"><?php echo $val['average']?></td>
<?php endif?>
</tr>
<?php endforeach?>
<tr >
<td colspan="2" style="text-align:center" class="border-left"><?php echo $this->translate('Average score')?></td>
<?php foreach($this->subject as $subjectArr):?>
<?php foreach($subjectArr as $row):?>
<td class="score border-center"><?php if(isset($this->studentScore['subjectAverage'][$row['subject_sn']]))echo $this->studentScore['subjectAverage'][$row['subject_sn']]?></td>
<?php endforeach?>
<?php endforeach?>
<?php if ($this->rankPrint):?>
<td colspan="3" class="border-right" ></td>
<?php else:?>
<td colspan="2" class="border-right" ></td>
<?php endif?>
</tr>
<tr class="border-center <?php if (!$this->signPrint):?>border-bottom-solid<?php endif?> " >
<td colspan="2"  class="border-left" style="text-align:center"><?php echo $this->translate('Standard deviation')?></td>
<?php foreach($this->subject as $subjectArr):?>
<?php foreach($subjectArr as $row):?>
<td class="border-center"  style="text-align:center;padding:2px"><?php if(isset($this->studentScore['subjectStd'][$row['subject_sn']]))echo $this->studentScore['subjectStd'][$row['subject_sn']]?></td>
<?php endforeach?>
<?php endforeach?>
<?php if ($this->rankPrint):?>
<td colspan="3" class="border-right" ></td>
<?php else:?>
<td colspan="2" class="border-right" ></td>
<?php endif?>
</tr>
<?php if ($this->signPrint):?>
<tr class="border-center border-bottom-solid" style="height:60px" >
<td colspan="2"  class="border-left" style="text-align:center"><?php echo $this->translate('teacher sign')?></td>
<?php foreach($this->subject as $subjectArr):?>
<?php foreach($subjectArr as $row):?>
<td class="border-center"  style="text-align:right;padding:2px"></td>
<?php endforeach?>
<?php endforeach?>
<?php if ($this->rankPrint):?>
<td colspan="3" class="border-right" ></td>
<?php else:?>
<td colspan="2" class="border-right" ></td>
<?php endif?>
</tr>
<?php endif?>

</tbody>
</table>

</div>